package cn.risebd.pay.conf;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.plugin.redis.Redis;
import com.jfinal.plugin.redis.RedisPlugin;

import cn.risebd.wechat.sdk.api.ApiConfigKit;
import cn.risebd.wechat.sdk.cache.RedisAccessTokenCache;

/**
 * TODO: 增加描述
 * 
 * @author yiz
 * @date 2016年5月13日 下午4:00:41
 * @version 1.0.0 
 * @copyright pycredit.cn 
 */
public class PayConfig extends JFinalConfig {

	@Override
	public void configConstant(Constants me) {
		// TODO Auto-generated method stub

	}

	@Override
	public void configRoute(Routes me) {
		// TODO Auto-generated method stub

	}

	@Override
	public void configPlugin(Plugins me) {
		RedisPlugin redisPlugin = new RedisPlugin("weixin", "127.0.0.1");
		me.add(redisPlugin);
	}

	@Override
	public void configInterceptor(Interceptors me) {
		// TODO Auto-generated method stub

	}

	@Override
	public void configHandler(Handlers me) {
		// TODO Auto-generated method stub

	}

	public void afterJFinalStart() {
		// 1.5 之后支持redis存储access_token、js_ticket，需要先启动RedisPlugin
		//		ApiConfigKit.setAccessTokenCache(new RedisAccessTokenCache());
		// 1.6新增的2种初始化
		ApiConfigKit.setAccessTokenCache(new RedisAccessTokenCache(Redis.use("weixin")));
		//		ApiConfigKit.setAccessTokenCache(new RedisAccessTokenCache("weixin"));
	}

}
